package be.pluyckx.batteryprogress.activity.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.ads.AdView;

import be.pluyckx.batteryprogress.R;

/**
 * Created by Philip Luyckx on 23/08/13.
 *
 * A fragment for the AdMob.
 */
public class AdMobFragment extends Fragment {
  private ViewGroup mRoot = null;
  private AdView mAdView = null;

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRoot = (ViewGroup) inflater.inflate(R.layout.fragment_admob, container, false);

    if (mRoot != null) {
      mAdView = (AdView) mRoot.findViewById(R.id.ad_view);
    }

    return mRoot;
  }

  @Override
  public void onDestroyView() {
    super.onDestroyView();

    if (mAdView != null) {
      mRoot.removeView(mAdView);
      mAdView.destroy();
      mAdView = null;
      mRoot = null;
    }
  }
}
